Skip to content

ENH: (GH4629) Support for using a DatetimeIndex/PeriodsIndex directly in a datelike calculation #4641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 24, 2013

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Aug 22, 2013

closes #4629

In [1]: s = Series(date_range('20130101',periods=5),index=date_range('20130102',periods=5))

In [2]: s
Out[2]: 
2013-01-02   2013-01-01 00:00:00
2013-01-03   2013-01-02 00:00:00
2013-01-04   2013-01-03 00:00:00
2013-01-05   2013-01-04 00:00:00
2013-01-06   2013-01-05 00:00:00
Freq: D, dtype: datetime64[ns]

In [3]: s-s.index
Out[3]: 
2013-01-02   -1 days, 00:00:00
2013-01-03   -1 days, 00:00:00
2013-01-04   -1 days, 00:00:00
2013-01-05   -1 days, 00:00:00
2013-01-06   -1 days, 00:00:00
Freq: D, dtype: timedelta64[ns]

@jreback
Copy link
Contributor Author

jreback commented Aug 22, 2013

cc @jtratner @cpcloud comments?

Any other index combinations you think I should try?

As an aside, this does not work (nor should it)

s = Series(randn(10),index=date_range('20130101',periods=10))
s.index-s

as this is an Index set operation (you could of course extract the index from the rhs, but that's not that interesting)

lvalues = convert_to_array(lvalues)
rvalues = convert_to_array(rvalues)
lvalues,_ = convert_to_array(lvalues)
rvalues,other = convert_to_array(rvalues,other)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

am I reading this wrong, or are you converting other to None unless it's a PeriodIndex or DatetimeIndex?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope...it comes in an out as the same (unless the date/period indexdex convert it)...I needed to do this because its needed below...a bit hacky, but didn't see a better way around it

@jreback
Copy link
Contributor Author

jreback commented Aug 23, 2013

@jtratner ok otherwise?

jreback added a commit that referenced this pull request Aug 24, 2013
ENH: (GH4629) Support for using a DatetimeIndex/PeriodsIndex directly in a datelike calculation
@jreback jreback merged commit f2a7b9c into pandas-dev:master Aug 24, 2013
@jtratner
Copy link
Contributor

@jreback sorry about that - can only work on this outside of work (and I just realized that I just misread earlier)

@jreback
Copy link
Contributor Author

jreback commented Aug 24, 2013

@jtratner np.....I am out of the office next week...so had a really light week this week....got a lot done!

@nehalecky
Copy link
Contributor

Epic. Thank you much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: arithmetic ops could accept an index as appropriate
3 participants